home *** CD-ROM | disk | FTP | other *** search
- <!--- This example shows the use of ArraySum --->
- <HTML>
- <HEAD>
- <TITLE>ArraySum Example</TITLE>
- </HEAD>
-
- <BASEFONT FACE="Arial, Helvetica" SIZE=2>
- <BODY bgcolor="#FFFFD5">
-
- <H3>ArraySum Example</H3>
- <P>
- If this example doesn't run or returns
- erroneous results, you may need to
- either create the snippets collection
- (using the CFCOLLECTION example) or populate
- the snippets collection (using the CFINDEX example).
- <HR>
- <!--- create an array --->
- <CFSET myNumberArray = ArrayNew(1)>
- <!--- run a standard search --->
- <CFSEARCH NAME="SearchSnippets"
- COLLECTION="snippets"
- TYPE="simple"
- CRITERIA="Array*">
- <!--- set a temp variable --->
- <CFSET temp = 1>
- <!--- output the results of the search --->
- <CFOUTPUT QUERY="SearchSnippets">
- <CFSET myNumberArray[temp] = score>
- <CFSET temp = temp + 1>
- </CFOUTPUT>
- <!--- use ArrayAvg to get the average score --->
- <P>The average score for your search on the term
- "Array*" in the collection "Snippets" is
- <CFOUTPUT>
- #ArrayAvg(myNumberArray)# for
- #SearchSnippets.RecordCount# "hits"<BR>
- <P>The sum of the elements in the array is
- #ArraySum(myNumberArray)#
- </CFOUTPUT>
-
- </BODY>
- </HTML>
-